<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <base href="<%=basePath%>"/>
    <title>Title</title>
    <script src="static/javascript/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" language="JavaScript">
        $(document).ready(function(){
            $(".showNotice").click(function () {
                obj=$.ajax({url:"admin/editManage/noticeShow?noticeId=" + $(this).attr("name"),async:false});
                $("#editMain").html(obj.responseText);
            });
            $(".editNotice").click(function () {
                obj=$.ajax({url:"admin/editManage/noticeEdit?noticeId=" + $(this).attr("name"),async:false});
                $("#editMain").html(obj.responseText);
            });
            $(".deleteNotice").click(function () {
                if(confirm("是否确认删除？")) {
                    obj = $.ajax({url: "admin/editManage/noticeDelete?noticeId=" + $(this).attr("name"), async: false});
                    alert(obj.responseText);
                    $("#editNoticeManage").click();
                }
            });
            $("#addNewNotice").click(function () {
                $("#editMain").load("views/admin/editManage/noticeCreate.jsp");
            });
        });
    </script>
</head>
<body>
<div>
    <table>
        <tr>
            <th>编号</th>
            <th>公告列表</th>
            <th>发表时间</th>
            <th>编辑公告</th>
            <th>删除公告</th>
        </tr>
        <c:forEach items="${noticeList}" var="notice" varStatus="vs">
            <tr>
                <td>${vs.index + 1}</td>
                <td><a class="showNotice" name="${notice.id}">${notice.title}</a></td>
                <td><spring:eval expression="notice.submitTime"></spring:eval></td>
                <td><a class="editNotice" name="${notice.id}">编辑公告</a></td>
                <td><a class="deleteNotice" name="${notice.id}">删除公告</a></td>
            </tr>
        </c:forEach>
    </table>
    <button id="addNewNotice">新增公告</button>
</div>
</body>
</html>